package cn.springboot.controller;


import cn.springboot.mapper.UserMapper;
import cn.springboot.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class IndexController {
    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/index")
    public String indexController(){
      return "index";
    }
    @ResponseBody
    @RequestMapping("/getUserByname")
  public   User findByName(String username){
        return userMapper.findByName(username);
  }


  @ResponseBody
   @RequestMapping("/addUser")
    public String insert(String username,String password){
      userMapper.insert(username,password);
      return "success";
    }
}
